#include "pch.h"
			
				std::vector<techlego::pos2d> read_asc_file(const std::wstring& path)
			
				{
			
				std::ifstream ifs(path);
			
				std::string line;
			
				std::vector<techlego::pos2d>res;
			
				while (std::getline(ifs, line))
			
				{
			
				if (line.empty())
			
				{
			
				continue;
			
				}
			
				float d0{};
			
				float d1{};
			
				float d2{};
			
				float d3{};
			
				float d4{};
			
				float d5{};
			
				sscanf_s(line.data(), "%f %f %f %f %f %f", &d0, &d1, &d2, &d3, &d4, &d5);
			
				res.emplace_back(techlego::pos2d{ d0, d1 });
			
				}
			
				return res;
			
				}
			
				int main()
			
				{
			
				//測(cè)試數(shù)據(jù)路徑
			
				std::wstring data_path = L"D:\\soft_product1\\techlego_sdk\\C++\\examples\\擬合2d圓\\data.asc";
			
				//讀取測(cè)試數(shù)據(jù)
			
				std::vector<techlego::pos2d> points = read_asc_file(data_path);
			
				double x{}, y{}, r{};
			
				//進(jìn)行2D圓粗?jǐn)M合
			
				auto error = techlego::fit_circle_fast(points, x, y, r);
			
				
			
				std::cout << "error:" << error << "\n";
			
				std::cout << "x:" << x << "\n";
			
				std::cout << "y:" << y << "\n";
			
				std::cout << "r:" << r << "\n\n";
			
				//根據(jù)粗?jǐn)M合的結(jié)果再進(jìn)行2D圓擬合
			
				error = techlego::fit_cricle_fine(points, x, y, r);
			
				std::cout << "error:" << error << "\n";
			
				std::cout << "x:" << x << "\n";
			
				std::cout << "y:" << y << "\n";
			
				std::cout << "r:" << r << "\n";
			
				return 0;
			
				}